@use "sass:math";

@function tint($color, $percentage) {
  @return mix(transparent, $color, $percentage);
}

@function shade($color, $percentage) {
  @return mix(black, $color, $percentage);
}

@function toRem($px) {
  @return #{math.div($px, 16px)}rem;
}

@function rgba-to-rgb($rgba, $opacity: 0, $background: #fff) {
  @if $opacity > 0 {
    @if $opacity < 1 {
      $opacity: $opacity * 100;
    }
    @return mix(
      mix(
        rgb(red($rgba), green($rgba), blue($rgba)),
        $background,
        alpha($rgba) * 100%
      ),
      rgb(255, 255, 255),
      $opacity
    );
  }
  @return mix(
    rgb(red($rgba), green($rgba), blue($rgba)),
    $background,
    alpha($rgba) * 100%
  );
}
